//
//  HX_AddStudent.m
//  08 - UItableVIew
//
//  Created by 韩旭 on 16/7/25.
//  Copyright © 2016年 lanou. All rights reserved.
//

#import "HX_AddStudent.h"
#import "HX_ Details.h"
#import "ViewController.h"
#import "Model.h"
@interface HX_AddStudent ()
@property (nonatomic, strong) UIButton *btnAdd;
@property (nonatomic, strong) UITextField *fieldName;
@property (nonatomic, strong) UITextField *filedAge;
@property (nonatomic, strong) UITextField *fieldTele;
@property (nonatomic, strong) UITextField *fieldGender;


@end

@implementation HX_AddStudent
- (void)viewDidLoad {
    [super viewDidLoad];
    self.edgesForExtendedLayout = UIRectEdgeNone;
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"添加联系人";
    [self creatFiled];
    [self creatBtn];
}
- (void)creatBtn {
    self.btnAdd = [UIButton buttonWithType:UIButtonTypeSystem];
    _btnAdd.frame = CGRectMake(0, 0, 120, 50);
    _btnAdd.center = CGPointMake(WIDETH / 2, HEIGHT * 0.6);
    [_btnAdd setTitle:@"保存" forState:UIControlStateNormal];
    _btnAdd.backgroundColor = COLORAUTO;
    [self.view addSubview:_btnAdd];
    [_btnAdd addTarget:self action:@selector(pushToView:) forControlEvents:UIControlEventTouchUpInside];
}
- (void)creatFiled {
    self.fieldName = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, kWidth, 50)];
    _fieldName.backgroundColor = COLORAUTO;
    _fieldName.placeholder = @"请输入添加的名字";
    [self.view addSubview:_fieldName];
    
    self.filedAge = [[UITextField alloc] initWithFrame:CGRectMake(0, _fieldName.frame.size.height + _fieldName.frame.origin.y, kWidth, _fieldName.frame.size.height)];
    _filedAge.placeholder = @"请输入年龄";
    [self.view addSubview:_filedAge];
    
    self.fieldTele = [[UITextField alloc] initWithFrame:CGRectMake(0, _filedAge.frame.size.height + _filedAge.frame.origin.y, kWidth, _filedAge.frame.size.height)];
     _fieldTele.placeholder = @"请输入电话";
    [self.view addSubview:_fieldTele];
    
    self.fieldGender = [[UITextField alloc] initWithFrame:CGRectMake(0, _fieldTele.frame.size.height + _fieldTele.frame.origin.y, kWidth, _fieldTele.frame.size.height)];
    _fieldGender.placeholder = @"请输入性别";
    [self.view addSubview:_fieldGender];
}
- (void)pushToView:(UIButton *)btn {
    Model *model = [[Model alloc] init];
    model.name = _fieldName.text;
    model.age = [_filedAge.text integerValue];
    model.phoneNumber = _fieldTele.text;
    model.gender = _fieldGender.text;
    [self.delegate addName:model];
    [self.navigationController popViewControllerAnimated:YES];
}
@end
